package com.example.customview

import android.graphics.Color
import com.alibaba.android.arouter.facade.annotation.Route
import com.android.baselibrary.arouter.ArouterContains
import com.android.baselibrary.base.BaseActivity
import com.android.baselibrary.base.CommonRouterManger
import com.android.baselibrary.recycler.BaseRecycleViewAdapter
import com.android.baselibrary.recycler.linear
import com.android.baselibrary.view.borderStyle
import com.example.customview.arouter.CustomArouter
import com.example.customview.bean.CustomBean
import com.example.customview.databinding.ActivityCustomViewMainBinding
import com.example.customview.databinding.LayoutCustomViewBinding


@Route(path = ArouterContains.VIEW_MODEL)
class CustomViewMainActivity : BaseActivity<ActivityCustomViewMainBinding>() {
    override fun getLayoutId(): Int = R.layout.activity_custom_view_main

    override fun initView() {
        /* mBinding.viewPager.adapter =object :FragmentStateAdapter(supportFragmentManager,lifecycle){
          override fun getItemCount(): Int  = data.size

          override fun createFragment(position: Int): Fragment {
            return  ARouter.getInstance().build(data[position].path).navigation() as Fragment
          }

      }
     val  tabLayoutMediator =  TabLayoutMediator(mBinding.tabLayout,mBinding.viewPager
       ) { tab, position ->
         tab.text = data[position].name.lowercase()
     }
        tabLayoutMediator.attach()

    }*/
        mBinding.recyclerViewView.linear().adapter = object :
            BaseRecycleViewAdapter<CustomBean, LayoutCustomViewBinding>(R.layout.layout_custom_view) {
            override fun covert(binding: LayoutCustomViewBinding, t: CustomBean, position: Int) {
                binding.tvName.text = t.name
                binding.tvName.borderStyle(4, Color.parseColor("#FFBB86FC"), 1)
            }
        }.apply {
            setData(data)
        }.setOnItemClickListener { data, _ ->
            CommonRouterManger.instance.navigationActivityParams(
                CustomArouter.CUSTOM_CONTAINER_ACTIVITY,
                CustomArouter.EXTRA_KEY_FRAGMENT_PATH to data.path
            )
        }
    }


    override fun initListener() {

    }


    private val data: MutableList<CustomBean> by lazy {
        mutableListOf(
            CustomBean("扩展view", CustomArouter.CUSTOM_EXPAND_VIEW),
            CustomBean("加载条", CustomArouter.CUSTOM_LOADING_VIEW),
            CustomBean("进度条", CustomArouter.CUSTOM_PROGRESS_VIEW),
            CustomBean("BehaviorView", CustomArouter.CUSTOM_BEHAVIOR_VIEW),
            CustomBean("水波纹", CustomArouter.CUSTOM_WAVE_VIEW),
            CustomBean("SlideBar", CustomArouter.CUSTOM_INDEX_BAR),
            CustomBean("GradientView", CustomArouter.CUSTOM_GRADIENT_TEXT),
            CustomBean("FlowLayout", CustomArouter.CUSTOM_FLOWLAYOUT_ACTIVITY),
            CustomBean("滑动冲突", CustomArouter.CUSTOM_SCROLLER_EVENT_ACTIVITY),
            CustomBean("PhotoView", CustomArouter.CUSTOM_PHOTO_VIEW_FRAGMENT),
            CustomBean("列表头部悬停", CustomArouter.CUSTOM_HEAD_HOVER_FRAGMENT),
            CustomBean("自定义布局", CustomArouter.CUSTOM_TITLE_BAR_FRAGMENT),
            CustomBean("自定义ViewPage", CustomArouter.CUSTOM_HORIZONTAL_FRAGMENT),
            CustomBean("自定义Drawable", CustomArouter.CUSTOM_DRAWABLE_FRAGMENT),
            CustomBean("贝塞尔曲线", CustomArouter.CUSTOM_BEZIER_MAIN_FRAGMENT),
            CustomBean("倒计时", CustomArouter.CUSTOM_CUT_DOWN_TIME_FRAGMENT),


            )
    }

}

